package main

import "fmt"

/**
 * @param bookings: Flight booking information
 * @param n: Total number of flights
 * @return: Number of seats booked per flight
 */
func CorpFlightBookings(bookings [][]int, n int) []int {
	//差分数组
	d := make([]int, n+2)
	for _, v := range bookings {
		start := v[0]
		end := v[1]
		val := v[2]

		d[start] += val
		d[end+1] -= val
	}

	s := 0
	ans := make([]int, n)
	for i := 1; i <= n; i++ {
		s += d[i]
		ans[i-1] = s
	}
	return ans
}

func main() {

	arr := [][]int{{1, 2, 10}, {2, 4, 20}, {2, 5, 25}}
	fmt.Println(CorpFlightBookings(arr, 5))
}
